<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul {
            list-style: none;
        }

        .box {
            width: 500px;
            height: 240px;
            margin: 50px auto 0;
            position: relative;
        }

        .circle {
            width: 100px;
            height: 50px;
            display: flex;
            justify-content: space-around;
            align-items: center;
            position: absolute;
            right: 20px;
            bottom: 0px;
        }

        .circle>li {
            width: 10px;
            height: 10px;
            border: 1px solid black;
            border-radius: 50%;

        }

        .circle>.reveal {
            background-color: orange;
        }

        .picture {
            width: 100%;
            height: 100%;
        }

        .picture>li {
            width: 100%;
            height: 100%;
            display: none;
        }

        .picture>li>img {
            width: 100%;
            height: 100%;
        }

        .picture>.show {
            display: block;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul class="circle">
            <li class="reveal"></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <ul class="picture">
            <li class="show">
                <img src="../images/1.jpg" alt="">
            </li>
            <li>
                <img src="../images/2.jpg" alt="">
            </li>
            <li>
                <img src="../images/3.webp" alt="">
            </li>
            <li>
                <img src="../images/4.webp" alt="">
            </li>
        </ul>
    </div>
</body>
<script>
    var box = document.getElementsByClassName("box")[0];
    var circleList = document.querySelectorAll(".circle li");
    var pictureList = document.querySelectorAll(".picture li");

    var index = 0;

    for (let i = 0; i < circleList.length; i++) {
        let li = circleList[i];
        li.onclick = function () {
            index = i;
            for (var j = 0; j < circleList.length; j++) {
                circleList[j].className = "";
                pictureList[j].className = "";
            }
            circleList[index].className = "reveal";
            pictureList[index].className = "show";
        }
    }
    var shuffling = setInterval(function () {
        index++;
        if (index >= circleList.length) {
            index = 0;
        }
        for (var j = 0; j < circleList.length; j++) {
            circleList[j].className = "";
            pictureList[j].className = "";
        }
        circleList[index].className = "reveal";
        pictureList[index].className = "show";
    }, 3000)

    box.onmouseover = function () {
        clearInterval(shuffling);
        console.log(11);
    }
    box.onmouseout = function () {
        console.log(22);
        shuffling = setInterval(function () {
            index++;
            if (index >= circleList.length) {
                index = 0;
            }
            for (var j = 0; j < circleList.length; j++) {
                circleList[j].className = "";
                pictureList[j].className = "";
            }
            circleList[index].className = "reveal";
            pictureList[index].className = "show";
        }, 3000)
    }
</script>

</html>